﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.PoseEditor.CApKinPoseEditorMoveToPose
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.CycleTimeReport;
using EngineeringInternalExtension;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.PoseEditor;

public class CApKinPoseEditorMoveToPose
{
  private ITxDevice m_device;
  private TxPose m_targetPose;

  public CApKinPoseEditorMoveToPose(ITxDevice device, TxPose targetPose)
  {
    this.m_device = device;
    this.m_targetPose = targetPose;
  }

  public void MoveToPose()
  {
    this.PlaySimulation();
    TxApplication.ActiveUndoManager.ClearAllTransactions();
  }

  private void PlaySimulation()
  {
    TxSimulationPlayer simulationPlayer = new TxSimulationPlayer(true, true);
    bool ignoreSignals = TxSimulationPlayer.IgnoreSignals;
    TxSimulationPlayer.IgnoreSignals = true;
    CApCTRToggleCmd capCtrToggleCmd = new CApCTRToggleCmd();
    bool flag = capCtrToggleCmd.IsCycleTimeReportActivated();
    if (flag)
      capCtrToggleCmd.ActivateCycleTimeReport(false);
    TxSimulationPlayerEx.DisableReset(simulationPlayer);
    simulationPlayer.SetMoveDeviceToPose(this.m_device, this.m_targetPose);
    simulationPlayer.Play();
    TxSimulationPlayer.IgnoreSignals = ignoreSignals;
    if (flag)
      capCtrToggleCmd.ActivateCycleTimeReport(true);
    simulationPlayer.ResetToDefaultSetting();
  }
}
